package br.com.sadim.web;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
import javax.servlet.http.HttpServletResponse;

import br.com.sadim.diagnostico.Doenca;
import br.com.sadim.diagnostico.DoencaRN;
import br.com.sadim.diagnostico.Sintoma;
import br.com.sadim.diagnostico.SintomaRN;
import br.com.sadim.hospital.Consulta;
import br.com.sadim.hospital.Exame;
import br.com.sadim.hospital.ExameRN;

@ManagedBean(name="exameBean")
@RequestScoped
public class ExameBean implements Serializable {

	private static final long serialVersionUID = 1L;
	private Exame exame = new Exame();
	private ExameRN exameRN = new ExameRN();
	private List<Exame> lista;
	
	private ConsultaBean consultaBean;


	public String salvar() {
		exameRN.salvar(getExame());
		return "listagemConsulta";
	}

	public String edit(){
		return "exame";
	}

	public String delete(){
		exameRN.delete(getExame());
		return "exameExcluida";
	}


	public List<Exame> getLista() {
		if(lista==null) {
			lista = exameRN.getList();
		}
		return lista;
	}

	public String novoExame() {
		return "exame";
	}
	public Exame getExame() {
		return exame;
	}

	public void setExame(Exame exame) {
		this.exame = exame;
	}


	public String adicionar() {
		exame.setConsulta(consultaBean.getConsulta());
		lista = consultaBean.getConsulta().getExame();
		if(lista == null || lista.isEmpty()) {
			lista = new ArrayList<Exame>();
		}
		lista.add(exame);
		consultaBean.getConsulta().setExame(lista);
		
		return "listagemConsulta";
	}
	
	public ConsultaBean getConsultaBean() {
		return consultaBean;
	}

	public void setConsultaBean(ConsultaBean consultaBean) {
		this.consultaBean = consultaBean;
	}
}
